<?php

session_start(); 
$username=$_SESSION['username'];
//$username = $_POST['cuid'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$country = $_POST['country'];
$zipcode = $_POST['zipcode'];
$cellnumber = $_POST['cellnumber'];

//echo 'Message'.$username.$address1.$address2.$city.$state.$country.$zipcode.$cellnumber;

/*$username='jhg1234';
//$username = $_POST['cuid'];
$address1 = 'pppp';
$address2 = 'pppp';
$city = 'pppp';
$state = 'pppp';
$country = 'pppp';
$zipcode = '12345';
$cellnumber = '1234567899';*/

$conn = oci_connect("gaurav", "gaurav", "xe"); 
//$db = "w4111b.cs.columbia.edu:1521/adb"; 
 
//$conn = oci_connect("gip2103", "rdVICpH", $db);  

$stmt = "UPDATE Candidate SET cuid = '$username', address1 = :address1, address2 = :address2, city = :city, state = :state, country = :country, zipcode = :zipcode, cellnumber = :cellnumber WHERE cuid like '$username'"; 
 
$bindargs1 = array();
array_push($bindargs1, array('ADDRESS1', $address1, -1));
array_push($bindargs1, array('ADDRESS2', $address2, -1));
array_push($bindargs1, array('CITY', $city, -1));
array_push($bindargs1, array('STATE', $state, -1));
array_push($bindargs1, array('COUNTRY', $country, -1));
array_push($bindargs1, array('ZIPCODE', $zipcode, -1));
array_push($bindargs1, array('CELLNUMBER', $cellnumber, -1));
 
$r = db_execute_statement($conn, $stmt, $bindargs1);
header('Location: /StudentHomePageProfile.php');

function db_execute_statement($conn, $statement, $bindvars = array())
{
  $stid = oci_parse($conn, $statement);
  if (!$stid) {
    db_error($conn, __FILE__, __LINE__);
  }
    // Bind parameters
  foreach ($bindvars as $b) {
    // create local variable with caller specified bind value 
    $$b[0] = $b[1];
    $r = oci_bind_by_name($stid, ":$b[0]", $$b[0], $b[2]);
    if (!$r) {
      db_error($stid, __FILE__, __LINE__);
    }
  }

  $r = oci_execute($stid);
  if (!$r) {
    db_error($stid, __FILE__, __LINE__);
  }
  return($r);
}

?>